<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        Date.prototype.getString = function() {

            function change(num) {
                return num <= 10 ? '0' + num : "" + num;
            }

            return `${this.getFullYear()}-${change(this.getMonth() + 1)}-${change(this.getDate())} ${change(this.getHours())}:${change(this.getMinutes())}:${change(this.getSeconds())}`
        }

        let date1 = new Date();
        date1.setHours(20);

        let date2 = new Date();

        let str = date1.getString();
        console.log(str);

        str = date2.getString();
        console.log(str);

    </script>
</body>
</html>